LurchTable stands for "Least Used Recently Concurrent Hash Table" and has definate similarities to both the .NET 4 ConcurrentDictionary as well as Java's LinkedHashMap. This gives you a thread-safe dictionary/hashtable that stores element ordering by insertion, updates, or access. In addition it can be configured to use a 'hard-limit' count of items that will automatically 'pop' the oldest item in the collection.
Object Model
Syntax
Type Parameters
- TKey
- The type of keys in the dictionary.
- TValue
- The type of values in the dictionary.
Example
Library/Library.Test/TestLurchTable.cs
C# | Copy Code |
---|
//multiple of prime will produce hash collision, thus testing removal of non-first elements
const int prime = 1103;
var test = new LurchTable<int, string>(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer<int>.Default);
test[1 * prime] = "a";
test[2 * prime] = "b";
test[3 * prime] = "c";
test[4 * prime] = "d";
test[5 * prime] = "e";
Assert.IsTrue(test.Remove(4 * prime));
Assert.IsTrue(test.Remove(2 * prime));
Assert.IsTrue(test.Remove(5 * prime));
Assert.IsTrue(test.Remove(1 * prime));
Assert.IsTrue(test.Remove(3 * prime));
Assert.AreEqual(0, test.Count); |
VB.NET | Copy Code |
---|
'multiple of prime will produce hash collision, thus testing removal of non-first elements
Const prime As Integer = 1103
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 10, prime, 10, 10, EqualityComparer(Of Integer).[Default])
test(1 * prime) = "a"
test(2 * prime) = "b"
test(3 * prime) = "c"
test(4 * prime) = "d"
test(5 * prime) = "e"
Assert.IsTrue(test.Remove(4 * prime))
Assert.IsTrue(test.Remove(2 * prime))
Assert.IsTrue(test.Remove(5 * prime))
Assert.IsTrue(test.Remove(1 * prime))
Assert.IsTrue(test.Remove(3 * prime))
Assert.AreEqual(0, test.Count) |
Inheritance Hierarchy
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also